<?php if( !defined( 'MAIN_DIR' ) ) { header( 'Location: ' . dirname( PHP_SELF ) . '/' ); exit( ); }
	$file = ( isset( $file ) ? $file : new File( ) );
	
	// 250 x 300
	$errors = null;

	if( isset( $_POST['file_updateProperties'] ) || isset( $_POST['file_updateProperties_x'] ) )	{
		if( isset( $_FILES['image'] ) && $_FILES['image']['name'] )	{
			if( in_array( $_FILES['image']['type'], array( 'image/jpeg', 'image/jpg', 'image/pjpeg' ) ) )	{
				if( $file->getProperty( 'image' ) )	{
					deleteUpload( $file->getProperty( 'image' ) );
					$file->setProperty( 'image', null );
					$file->setProperty( 'image_width', null );
					$file->setProperty( 'image_height', null );
				}
				
				$name = $width = $height = $ext = null;
				list( $name, $errors, $width, $height, $ext ) = uploadImage( 'image', 230, 230, UPLOAD_MINIMAL );
				if( !$errors )	{
					list( $newName, $width, $height ) = saveShapedImage( UPLOADS_DIR . toFS( $name ) . '.' . $ext, 735, 230, UPLOADS_DIR . toFS( $name ) . '.' . $ext );
					$file->setProperty( 'image', $name . '.' . $ext, Properties::TYPE_ATTACHMENT );
					$file->setProperty( 'image_width', $width );
					$file->setProperty( 'image_height', $height );
				}
				$file->commitProperties( );
			}
			else
				$errors = array( 'Selected image is not a JPG file.' );
		}
	}
?>
<div class="tableHolder">
	<table summary="File Data" border="0" cellspacing="0" cellpadding="5">
	<tr>
		<td><b>Nombre del contenido actual:</b></td>
		<td><input type="text" name="file_name" id="file_name" value="<?= $file->getName( ) ?>" class="inputText" style="width: 250px;" /></td>
		<td><input type="image" name="file_update" value="Update" src="images/save.png" style="width:16px;height:16px" title="Update" alt="Update"/></td>
	</tr>
	</table>
</div>
<?php toTitle( '<img src="images/attach.png" width="16" height="16" title="Attach" alt="Attach"/>&nbsp;<b>Contenido de Nosotros:</b>' )?>
<div id="fileDataHolder" style="top:96px;padding:5px;">
	<table summary="Photo content" border="0" cellspacing="0" cellpadding="5">
<?php
	if ( $errors )	{
?>
	<tr>
		<td class="textError"><?php echo implode( '<br />', $errors ) ?></td>
	</tr>
<?php
	}
?>
	<tr>
		<td align="center">
<?php
	if ( $file->getProperty( 'image' ) )	{
?>
			<a target="imaged" href="download.php?filename=<?= $file->getProperty( 'image' ) ?>"><img src="../uploads/<?= toURL( $file->getProperty( 'image' ) ) ?>" alt="" border="0" /></a>
			<br />
			<?php echo $file->getProperty( 'image_width' ) . 'px x ' . $file->getProperty( 'image_height' ) . 'px' ?>
			<br />
<?php
	}
?>
			<br />
            <input type="file" name="image" id="image" value="" class="inputText" />
            <br />
            Se recomienda una imagen de 735px de ancho por 230px de alto.
		</td>
	</tr>
	<tr>
		<td>
			<textarea name="journey" class="inputText" rows="2" cols="2" style="width:735px;height:200px;"><?php echo $file->getProperty( 'journey' ) ?></textarea>
            <br />
            <br />
            <input type="image" name="file_updateProperties" value="Update" src="images/save.png" style="width: 16px; height: 16px" title="Update" alt="Update"/>
		</td>
	</tr>
	</table>
</div>
